//对API进行统一管理
import requests from './ajax'
import mockRequests from './mockAjax'
//三级联动接口
export const reqCategoryList = () =>
  requests.get('/product/getBaseCategoryList')

//首页大轮播接口
export const reqBannerList = () => mockRequests.get('/banner')

//floor组件的数据
export const reqFloorList = () => mockRequests.get('/floor')

//搜索商品
export const reqSearchInfo = (params) =>
  requests({ url: '/list', method: 'post', data: params })

//获取商品详情
export const reqGoodsInfo = (skuid) =>
  requests({ url: `/item/${skuid}`, method: 'get' })

//添加到购物车
export const reqAddOrUpdateCart = (skuId, skuNum) =>
  requests({ url: `/cart/addToCart/${skuId}/${skuNum}`, method: 'post' })

//获取购物车列表数据
export const reqShopCartList = () =>
  requests({ url: '/cart/cartList', method: 'get' })

//删除购物车中商品
export const reqDeleteGoodsById = (skuId) =>
  requests({ url: `/cart/deleteCart/${skuId}`, method: 'delete' })

//修改购物车中商品的选中状态
export const reqUpdateCheckedByid = (skuId, isChecked) =>
  requests({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: 'get' })

//获取验证码
export const reqGetCode = (phone) =>
  requests({ url: `/user/passport/sendCode/${phone}`, method: 'get' })

//用户注册 带phone,code和password
export const reqUserRegister = (data) =>
  requests({ url: '/user/passport/register', data, method: 'post' })

//登录 带phone和password
//该接口不止返回了token，还返回了一些用户信息，一般只返回token，再拿着token向服务器拿信息
export const reqUserLogin = (data) =>
  requests({ url: '/user/passport/login', data, method: 'post' })

//获取用户信息 需要请求头里携带token
export const reqUserInfo = () =>
  requests({ url: '/user/passport/auth/getUserInfo', method: 'get' })
//退出登录
export const reqUserLogout = () =>
  requests({ url: '/user/passport/logout', method: 'get' })

//获取交易页信息
export const reqTradeInfo = () =>
  requests({ url: '/order/auth/trade', method: 'get' })

//获取用户地址信息
export const reqAddressInfo = () =>
  requests({ url: '/user/userAddress/auth/findUserAddressList', method: 'get' })

//提交订单
export const reqSubmitOrder = (tradeNo, data) =>
  requests({
    url: `/order/auth/submitOrder?tradeNo=${tradeNo}`,
    data,
    method: 'post'
  })

//获取订单支付信息
export const reqPayInfo = (orderId) =>
  requests({ url: `/payment/weixin/createNative/${orderId}`, method: 'get' })

//查询支付订单状态
export const reqOrderStatus = (orderId) =>
  requests({ url: `/payment/weixin/queryPayStatus/${orderId}`, method: 'get' })

//获取我的订单列表
export const reqMyOrderList = (page,limit) =>
  requests({ url: `/order/auth/${page}/${limit}`, method: 'get' })
